{include file="public/header"/}
<script src="{__ADMIN_PATH}/assets/module/colpick/js/colpick.js?t={php}echo time();{/php}"></script>
<link rel="stylesheet" href="{__ADMIN_PATH}/assets/module/colpick/css/colpick.css?t={php}echo time();{/php}" type="text/css"/>
</head>
<body>
<style>
  /*水印*/
  #bgcolor{border:solid 1px #ccc;width:70px;border-right:40px solid green;display:block;padding-left:10px;height:38px;line-height:1.3;border-style:solid;background-color:#fff;border-radius:2px;}
</style>
<div class="layui-form" id="LAY-component-layer-list">
    <div class="layui-fluid pd83">
        <div class="layui-card pcf30">
                  <div class="layui-form-item">
                    <label class="layui-form-label"><b class="pcfts">*</b> 广告标题</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="title" id="title" value="{$info.title|default=''}" class="layui-input" lay-verType="tips" lay-verify="required" required>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">上传图片</label>
                    <div class="layui-input-inline auto">
                      <ul class="layout">
                        <li>
                        <input name="litpic" id="litpic" placeholder="图片地址" value="{$info.litpic|default=''}" class="layui-input inp inp_logo">
                        <img id="img_litpic" src="{$info.litpic|get_default_pic=###}" class="none">
                        </li>
                        <li style="margin-top:3px;margin-left:5px;">
                          <div class="layui-btn-group">
                            <input type="button" value="上传图片" class="layui-btn layui-btn-sm pcfcms-upload" lay-data="{number:1,pcf_inputId:'litpic',pcf_savepath:'allimg'}">
                            <input type="button" value="选择图片" class="layui-btn layui-btn-sm" onClick="GetPictureFolder(1,'litpic');">
                            <input type="button" value="预览" class="layui-btn layui-btn-sm" onclick="BigImages($('#img_litpic').attr('src'));">
                            <input type="button" value="清除" class="layui-btn layui-btn-sm layui-btn-warm" data-inputid="litpic" onclick="DelImages(this);">
                          </div>
                        </li>
                      </ul>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label"> 链接网址</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="links" id="links" value="{$info.links|default=''}" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label"> 添加人</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="link_man" id="link_man" value="{$info.link_man|default=''}" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label"> 添加人邮箱</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="link_email" id="link_email" value="{$info.link_email|default=''}" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label"> 添加人电话</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="link_phone" id="link_phone" value="{$info.link_phone|default=''}" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label"> 投放时间</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="start_time" id="start_time" value="{$info.start_time|default=''}" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label"> 结束时间</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                     <input type="text" name="end_time" id="end_time" value="{$info.end_time|default=''}" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">广告描述</label>
                    <div class="layui-input-inline pcfcms_layui-input-inline">
                        <textarea name="intro" class="layui-textarea">{$info.intro|default=''}</textarea>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-inline">
                      <input type="text" name="sort_order" value="{$info.sort_order|default='100'}" lay-verify="number" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item texttr">
                    <label class="layui-form-label">背景颜色</label>
                    <div class="layui-input-inline">
                      <input type="text" name="bgcolor" value="{$info.bgcolor|default='#000000'}" id="bgcolor" style="border-color:{$info.bgcolor|default='#000000'};cursor:pointer;">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">新窗口打开</label>
                    <div class="layui-input-inline">
                        <input type="checkbox" lay-filter="target" lay-skin="switch" lay-text="是|否" {if $info.target==1}checked{/if}>
                        <input type="hidden" name="target" value="{$info.target|default='0'}"/>
                    </div>
                  </div>
                  <input type="hidden" name="id" value="{$info.id}">
                  <input type="hidden" name="pid" value="{$info.pid}">
        </div>
        <div class="pcfclear"></div>
    </div>
    <div class="submit-info text-center">
        <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
    </div>
</div>
{include file="public/footer"/}
<script>
layui.use(['layer', 'form'], function(){
    var $ = layui.$,
        layer = layui.layer,
        form = layui.form;
        form.render();

        // 监听开关
        form.on('switch', function(data){
          var elemId = data.elem.attributes['lay-filter']['nodeValue'];
          if (data.elem.checked) {
            this.value = 1;
          } else {
            this.value = 0;
          }
          $("input[name='"+elemId+"']").val(this.value);
        });

        //监听提交
        form.on('submit(formSubmit)', function(data){
            layer.msg('正在处理请勿刷新页面', {icon: 16,shade: 0.01,time:3600000});
            $.ajax({
                type : 'post',
                url : "{:url('/adposition/ad_edit')}",
                data : data.field,
                dataType : 'json',
                success : function(res){
                    layer.closeAll('loading');
                    if(res.status){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                            parent.window.location.href = res.url;
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                },
                error: function(e){
                    layer.closeAll('loading');
                    layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                }
            });
        });

        // 颜色选择
        $('#bgcolor').colpick({
            flat:false,
            layout:'rgbhex',
            submit:0,
            colorScheme:'light',
            color:$('#bgcolor').val(),
            onChange:function(hsb,hex,rgb,el,bySetColor) {
                $(el).css('border-color','#'+hex);
                if(!bySetColor) $(el).val('#'+hex);
            }
        }).keyup(function(){
            $(this).colpickSetColor('#'+this.value);
        });
        laydate.render({elem: '#start_time',type: 'datetime'});
        laydate.render({elem: '#end_time',type: 'datetime'});
        
});
</script>